<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        position: relative;
      }
      .menu {
        width: 100px;
        height: 40px;
        line-height: 40px;
        background-color: aqua;
      }
      .content {
        width: 200px;
        height: 100px;
        background-color: bisque;
        position: absolute;
        top: 0;
        left: 100px;
        display: none;
      }
    </style>
  </head>
  <body>
    <div class="menu">菜单1</div>
    <div class="menu">菜单二</div>
    <div class="content">内容1</div>
    <div class="content">内容2</div>
    <script>
      const menus = document.getElementsByClassName("menu");
      const contents = document.getElementsByClassName("content");
      for (let i = 0; i < menus.length; i++) {
        menus[i].onmouseover = function () {
          contents[i].style.display = "block";
        };
        menus[i].onmouseout = function () {
          contents[i].style.display = "none";
        };
      }
      for (let i = 0; i < contents.length; i++) {
        contents[i].onmouseover = function () {
          contents[i].style.display = "block";
        };
        contents[i].onmouseout = function () {
          contents[i].style.display = "none";
        };
      }
    </script>
  </body>
</html>
